<template>
  <div>
    <CategorySelector :isForbiddenForm="scene == 1"></CategorySelector>
    <el-card style="margin-top: 10px">
      <SpuList
        v-if="scene === 1"
        @changeScene="saveScene"
        @getSpuInfo="saveSpuInfo"
      ></SpuList>
      <SpuForm
        v-if="scene === 2"
        @changeScene="saveScene"
        :currentSpuInfo="currentSpuInfo"
      ></SpuForm>
      <SkuForm
        v-if="scene === 3"
        :currentSpuInfo="currentSpuInfo"
        @changeScene="saveScene"
      ></SkuForm>
    </el-card>
  </div>
</template>

<script lang="ts">
import CategorySelector from "@/components/CategorySelector/index.vue"
import SkuForm from "./components/SkuForm.vue"
import SpuForm from "./components/SpuForm.vue"
import SpuList from "./components/SpuList.vue"
export default {
  name: "Spu",
  components: { CategorySelector, SkuForm, SpuForm, SpuList },
}
</script>

<script lang="ts" setup>
import { ref } from "vue"
const scene = ref<number>(1)

const saveScene = (val: number) => {
  scene.value = val
}
const currentSpuInfo = ref([])
const saveSpuInfo = (spuInfo) => {
  // console.log('spuList',spuInfo)
  currentSpuInfo.value = {
    ...spuInfo,
    spuImageList: [], // 为了避免报错 需要添加上这两个属性
    spuSaleAttrList: [],
  }
}
</script>

<style></style>
